package com.central.apps.controller;

import com.central.app.common.base.BaseHandler;
import com.central.app.service.HandlerService;
import com.central.bizcommon.annotation.log.BussinessLog;
import com.central.common.web.Result;
import io.swagger.annotations.Api;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "定时任务")
@RequestMapping("/taskSchedule")
public class TaskScheduleController extends BaseHandler {

    @Autowired private HandlerService handlerService;

    @GetMapping("/findJobnum")
    public Result findJobnum (){
        int jobnumNew = 0;
        List<Map<String, Object>> bySql = handlerService.findBySql("select jobnum from task_schedule_job order by jobnum desc limit 1");
        if(CollectionUtils.isNotEmpty(bySql)){
            Map<String, Object> map = bySql.get(0);
            Integer jobnum = MapUtils.getInteger(map, "jobnum");
            jobnumNew = jobnum + 1;
        }
        return Result.succeed(jobnumNew,"成功");
    }

}
